package com.remiss.seckilldemo.controller;

import com.remiss.seckilldemo.service.IUserService;
import com.remiss.seckilldemo.vo.LoginVO;
import com.remiss.seckilldemo.vo.ResposeBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;


@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {
    @Autowired
    private IUserService iUserService;
    /**
     * 跳转登录界面
     * @return
     */
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

    @RequestMapping("/doLogin")
    @ResponseBody
    public ResposeBean doLogin(@Valid LoginVO loginVO, HttpServletRequest request, HttpServletResponse response){
        log.info(loginVO.getPassword() + loginVO.getMobile());
        return iUserService.doLogin(loginVO,request,response);

    }
}
